#include <iostream>

#include <ros/ros.h>
#include <signal.h>
#include <pthread.h>
#include <unistd.h>
#include <cmath>
#include <thread>

#include <node_test/Hello.h>


using namespace std;

bool stop = false;

//中断信号处理函数
void SigIntHandler(int sig)
{
	ROS_INFO("%s node leaved!", ros::this_node::getName().c_str());
	ros::shutdown();
	// stop = true;
}

int main(int argc, char *argv[])
{
	ros::init(argc, argv, "node_test", ros::init_options::NoSigintHandler);
	ros::NodeHandle nh;

    ROS_INFO("当前节点名: %s", ros::this_node::getName().c_str());

    //double
    ROS_INFO("当前时间: %lf", ros::Time::now().toSec());

    //int64
    ROS_INFO("当前时间: %ld", ros::Time::now().toNSec());

	//中断信号处理函数
	signal(SIGTERM, SigIntHandler);
    signal(SIGINT, SigIntHandler);

    ros::Rate rate(1);

	while (ros::ok() && !stop)
	{
        ROS_INFO("hello");
		rate.sleep();
	}

    ROS_INFO("status: %d", ros::isShuttingDown() && 1);

    ros::spin();

	return 0;
}
